home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / New System Software Extensions / Macintosh Drag and Drop 1.1.1 / Interfaces / Drag.a next >
Encoding:
Text File  |  1994-04-22  |  11.3 KB  |  636 lines  |  [TEXT/MPS ]

  1. ;
  2. ;    File:            Drag.a
  3. ;
  4. ;    Contains:        Assembly Interface for Drag Manager 
  5. ;
  6. ;    Copyright:        © 1993-1994 by Apple Computer, Inc., all rights reserved.
  7. ;
  8.  
  9.     IF &TYPE('__INCLUDINGDRAG__') = 'UNDEFINED' THEN
  10. __INCLUDINGDRAG__    SET    1
  11.  
  12.     IF &TYPE('__INCLUDINGFSEQU__') = 'UNDEFINED' THEN        ; get definition of FSSpec
  13.     INCLUDE     'FSEqu.a'
  14.     ENDIF
  15.  
  16.  
  17.  
  18. _DragDispatch            OPWORD        $ABED        ; will move to Traps.a
  19.  
  20.  
  21. ; Gestalt Selector and Response Constants
  22.  
  23. gestaltDragMgrAttr            EQU        'drag'        ; Drag Manager attributes
  24. gestaltDragMgrPresent        EQU        0            ; Drag Manager is present
  25. gestaltDragMgrFloatingWind    EQU        1            ; Drag Manager supports floating windows
  26. gestaltPPCDragLibPresent    EQU        2            ; Drag Manager PPC DragLib is present
  27.  
  28. gestaltTEAttr                EQU        'teat'        ; TextEdit attributes
  29. gestaltTEHasGetHiliteRgn    EQU        0            ; TextEdit has TEGetHiliteRgn
  30.  
  31.  
  32. ; Flavor Flags
  33.  
  34. flavorSenderOnly            EQU        $00000001    ; flavor is available to sender only
  35. flavorSenderTranslated        EQU        $00000002    ; flavor is translated by sender
  36. flavorNotSaved                EQU        $00000004    ; flavor should not be saved
  37. flavorSystemTranslated        EQU        $00000100    ; flavor is translated by system
  38.  
  39.  
  40. ; Drag Attributes
  41.  
  42. dragHasLeftSenderWindow        EQU        $00000001    ; drag has left the source window since TrackDrag
  43. dragInsideSenderApplication    EQU        $00000002    ; drag is occurring within the source application
  44. dragInsideSenderWindow        EQU        $00000004    ; drag is occurring within the source window
  45.  
  46.  
  47. ; Special Flavor Types
  48.  
  49. flavorTypeHFS                EQU        'hfs '        ; flavor type for HFS data
  50. flavorTypePromiseHFS        EQU        'phfs'        ; flavor type for promised HFS data
  51. flavorTypeDirectory            EQU        'diry'        ; flavor type for AOCE directories
  52.  
  53.  
  54. ; Drag Tracking Handler Messages
  55.  
  56. dragTrackingEnterHandler    EQU        1            ; drag has entered handler
  57. dragTrackingEnterWindow        EQU        2            ; drag has entered window
  58. dragTrackingInWindow        EQU        3            ; drag is moving within window
  59. dragTrackingLeaveWindow        EQU        4            ; drag has exited window
  60. dragTrackingLeaveHandler    EQU        5            ; drag has exited handler
  61.  
  62.  
  63. ; Drag Drawing Procedure Messages
  64.  
  65. dragRegionBegin                EQU        1            ; initialize drawing
  66. dragRegionDraw                EQU        2            ; draw drag feedback
  67. dragRegionHide                EQU        3            ; hide drag feedback
  68. dragRegionIdle                EQU        4            ; drag feedback idle time
  69. dragRegionEnd                EQU        5            ; end of drawing
  70.  
  71.  
  72. ; Zoom Acceleration
  73.  
  74. zoomNoAcceleration            EQU        0            ; use linear interpolation
  75. zoomAccelerate                EQU        1            ; ramp up step size
  76. zoomDecelerate                EQU        2            ; ramp down step size
  77.  
  78.  
  79. ; Result Codes - (will move to Errors.a)
  80.  
  81. badDragRefErr                EQU        -1850        ; unknown drag reference
  82. badDragItemErr                EQU        -1851        ; unknown drag item reference
  83. badDragFlavorErr            EQU        -1852        ; unknown flavor type
  84. duplicateFlavorErr            EQU        -1853        ; flavor type already exists
  85. cantGetFlavorErr            EQU        -1854        ; error while trying to get flavor data
  86. duplicateHandlerErr            EQU        -1855        ; handler already exists
  87. handlerNotFoundErr            EQU        -1856        ; handler not found
  88. dragNotAcceptedErr            EQU        -1857        ; drag was not accepted by receiver
  89.  
  90.  
  91. ; HFS Flavor
  92.  
  93. HFSFlavor        RECORD    0
  94. fileType        ds.b    4        ;    OSType        ; file type
  95. fileCreator        ds.b    4        ;    OSType        ; file creator
  96. fdFlags            ds.w    1        ;    INTEGER        ; Finder flags
  97. fileSpec        ds        FSSpec                    ; file system specification
  98. size            EQU        *
  99.                 ENDR
  100.  
  101.  
  102. ; Promise HFS Flavor
  103.  
  104. PromiseHFSFlavor    RECORD    0
  105. fileType        ds.b    4        ;    OSType        ; file type
  106. fileCreator        ds.b    4        ;    OSType        ; file creator
  107. fdFlags            ds.w    1        ;    INTEGER        ; Finder flags
  108. promisedFlavor    ds.b    4        ;    FlavorType    ; promised flavor containing FSSpec
  109. size            EQU        *
  110.                     ENDR
  111.  
  112.  
  113. ; Drag Manager Routines
  114.  
  115.  
  116. ; Installing and Removing Drag Handlers
  117.  
  118. ;
  119. ;    FUNCTION InstallTrackingHandler    (trackingHandler : DragTrackingHandler;
  120. ;                                     theWindow : WindowPtr;
  121. ;                                     handlerRefCon : UNIV Ptr) : OSErr;
  122. ;
  123.  
  124.     MACRO
  125.     _InstallTrackingHandler
  126.     moveq        #$01,d0
  127.     _DragDispatch
  128.     ENDM
  129.  
  130. ;
  131. ;    FUNCTION InstallReceiveHandler    (receiveHandler : DragReceiveHandler;
  132. ;                                     theWindow : WindowPtr;
  133. ;                                     handlerRefCon : UNIV Ptr) : OSErr;
  134. ;
  135.  
  136.     MACRO
  137.     _InstallReceiveHandler
  138.     moveq        #$02,d0
  139.     _DragDispatch
  140.     ENDM
  141.  
  142.  
  143. ;
  144. ;    FUNCTION RemoveTrackingHandler    (trackingHandler : DragTrackingHandler;
  145. ;                                     theWindow : WindowPtr) : OSErr;
  146. ;
  147.  
  148.     MACRO
  149.     _RemoveTrackingHandler
  150.     moveq        #$03,d0
  151.     _DragDispatch
  152.     ENDM
  153.  
  154.  
  155. ;
  156. ;    FUNCTION RemoveReceiveHandler    (receiveHandler : DragReceiveHandler;
  157. ;                                     theWindow : WindowPtr) : OSErr;
  158. ;
  159.  
  160.     MACRO
  161.     _RemoveReceiveHandler
  162.     moveq        #$04,d0
  163.     _DragDispatch
  164.     ENDM
  165.  
  166.  
  167.  
  168. ; Creating and Disposing Drag References
  169.  
  170. ;
  171. ;    FUNCTION NewDrag                (VAR theDragRef : DragReference) : OSErr;
  172. ;
  173.  
  174.     MACRO
  175.     _NewDrag
  176.     moveq        #$05,d0
  177.     _DragDispatch
  178.     ENDM
  179.  
  180.  
  181. ;
  182. ;    FUNCTION DisposeDrag            (theDragRef : DragReference) : OSErr;
  183. ;
  184.  
  185.     MACRO
  186.     _DisposeDrag
  187.     moveq        #$06,d0
  188.     _DragDispatch
  189.     ENDM
  190.  
  191.  
  192.  
  193. ; Adding Drag Item Flavors
  194.  
  195. ;
  196. ;    FUNCTION AddDragItemFlavor        (theDragRef : DragReference;
  197. ;                                     theItemRef : ItemReference;
  198. ;                                     theType : FlavorType;
  199. ;                                     dataPtr : UNIV Ptr;
  200. ;                                     dataSize : Size;
  201. ;                                     theFlags : FlavorFlags) : OSErr;
  202. ;
  203.  
  204.     MACRO
  205.     _AddDragItemFlavor
  206.     moveq        #$07,d0
  207.     _DragDispatch
  208.     ENDM
  209.  
  210.  
  211. ;
  212. ;    FUNCTION AddHFSFlavor            (theDragRef : DragReference;
  213. ;                                     theItemRef : ItemReference;
  214. ;                                     fileSpec : FSSpec;
  215. ;                                     theFlags : FlavorFlags) : OSErr;
  216. ;
  217.  
  218.     MACRO
  219.     _AddHFSFlavor
  220.     moveq        #$08,d0
  221.     _DragDispatch
  222.     ENDM
  223.  
  224.  
  225. ;
  226. ;    FUNCTION SetDragItemFlavorData    (theDragRef : DragReference;
  227. ;                                     theItemRef : ItemReference;
  228. ;                                     theType : FlavorType;
  229. ;                                     dataPtr : UNIV Ptr;
  230. ;                                     dataSize : Size;
  231. ;                                     dataOffset : LONGINT) : OSErr;
  232. ;
  233.  
  234.     MACRO
  235.     _SetDragItemFlavorData
  236.     moveq        #$09,d0
  237.     _DragDispatch
  238.     ENDM
  239.  
  240.  
  241.  
  242. ; Providing Drag Callback Procedures
  243.  
  244. ;
  245. ;    FUNCTION SetDragSendProc        (theDragRef : DragReference;
  246. ;                                     sendProc : DragSendDataProc;
  247. ;                                     dragSendRefCon : UNIV Ptr) : OSErr;
  248. ;
  249.  
  250.     MACRO
  251.     _SetDragSendProc
  252.     moveq        #$0A,d0
  253.     _DragDispatch
  254.     ENDM
  255.  
  256.  
  257. ;
  258. ;    FUNCTION SetDragInputProc        (theDragRef : DragReference;
  259. ;                                     inputProc : DragInputProc;
  260. ;                                     dragInputRefCon : UNIV Ptr) : OSErr;
  261. ;
  262.  
  263.     MACRO
  264.     _SetDragInputProc
  265.     moveq        #$0B,d0
  266.     _DragDispatch
  267.     ENDM
  268.  
  269.  
  270. ;
  271. ;    FUNCTION SetDragDrawingProc        (theDragRef : DragReference;
  272. ;                                     drawingProc : DragDrawingProc;
  273. ;                                     dragDrawingRefCon : UNIV Ptr) : OSErr;
  274. ;
  275.  
  276.     MACRO
  277.     _SetDragDrawingProc
  278.     moveq        #$0C,d0
  279.     _DragDispatch
  280.     ENDM
  281.  
  282.  
  283.  
  284. ; Performing a Drag
  285.  
  286. ;
  287. ;    FUNCTION TrackDrag                (theDragRef : DragReference;
  288. ;                                     theEvent : EventRecord;
  289. ;                                     theRegion : RgnHandle) : OSErr;
  290. ;
  291.  
  292.     MACRO
  293.     _TrackDrag
  294.     moveq        #$0D,d0
  295.     _DragDispatch
  296.     ENDM
  297.  
  298.  
  299.  
  300. ; Getting Drag Item Information
  301.  
  302. ;
  303. ;    FUNCTION CountDragItems            (theDragRef : DragReference;
  304. ;                                     VAR numItems : INTEGER) : OSErr;
  305. ;
  306.  
  307.     MACRO
  308.     _CountDragItems
  309.     moveq        #$0E,d0
  310.     _DragDispatch
  311.     ENDM
  312.  
  313.  
  314. ;
  315. ;    FUNCTION GetDragItemReferenceNumber
  316. ;                                    (theDragRef : DragReference;
  317. ;                                     index : INTEGER;
  318. ;                                     VAR theItemRef : ItemReference) : OSErr;
  319. ;
  320.  
  321.     MACRO
  322.     _GetDragItemReferenceNumber
  323.     moveq        #$0F,d0
  324.     _DragDispatch
  325.     ENDM
  326.  
  327.  
  328. ;
  329. ;    FUNCTION CountDragItemFlavors    (theDragRef : DragReference;
  330. ;                                     theItemRef : ItemReference;
  331. ;                                     VAR numFlavors : INTEGER) : OSErr;
  332. ;
  333.  
  334.     MACRO
  335.     _CountDragItemFlavors
  336.     moveq        #$10,d0
  337.     _DragDispatch
  338.     ENDM
  339.  
  340.  
  341. ;
  342. ;    FUNCTION GetFlavorType            (theDragRef : DragReference;
  343. ;                                     theItemRef : ItemReference;
  344. ;                                     index : INTEGER;
  345. ;                                     VAR theType : FlavorType) : OSErr;
  346. ;
  347.  
  348.     MACRO
  349.     _GetFlavorType
  350.     moveq        #$11,d0
  351.     _DragDispatch
  352.     ENDM
  353.  
  354.  
  355. ;
  356. ;    FUNCTION GetFlavorFlags            (theDragRef : DragReference;
  357. ;                                     theItemRef : ItemReference;
  358. ;                                     theType : FlavorType;
  359. ;                                     VAR theFlags : FlavorFlags) : OSErr;
  360. ;
  361.  
  362.     MACRO
  363.     _GetFlavorFlags
  364.     moveq        #$12,d0
  365.     _DragDispatch
  366.     ENDM
  367.  
  368.  
  369. ;
  370. ;    FUNCTION GetFlavorDataSize        (theDragRef : DragReference;
  371. ;                                     theItemRef : ItemReference;
  372. ;                                     theType : FlavorType;
  373. ;                                     VAR dataSize : Size) : OSErr;
  374. ;
  375.  
  376.     MACRO
  377.     _GetFlavorDataSize
  378.     moveq        #$13,d0
  379.     _DragDispatch
  380.     ENDM
  381.  
  382.  
  383. ;
  384. ;    FUNCTION GetFlavorData            (theDragRef : DragReference;
  385. ;                                     theItemRef : ItemReference;
  386. ;                                     theType : FlavorType;
  387. ;                                     dataPtr : UNIV Ptr;
  388. ;                                     VAR dataSize : Size;
  389. ;                                     dataOffset : LONGINT) : OSErr;
  390. ;
  391.  
  392.     MACRO
  393.     _GetFlavorData
  394.     moveq        #$14,d0
  395.     _DragDispatch
  396.     ENDM
  397.  
  398.  
  399. ;
  400. ;    FUNCTION GetDragItemBounds        (theDragRef : DragReference;
  401. ;                                     theItemRef : ItemReference;
  402. ;                                     VAR itemBounds : Rect) : OSErr;
  403. ;
  404.  
  405.     MACRO
  406.     _GetDragItemBounds
  407.     moveq        #$15,d0
  408.     _DragDispatch
  409.     ENDM
  410.  
  411.  
  412. ;
  413. ;    FUNCTION SetDragItemBounds        (theDragRef : DragReference;
  414. ;                                     theItemRef : ItemReference;
  415. ;                                     itemBounds : Rect) : OSErr;
  416. ;
  417.  
  418.     MACRO
  419.     _SetDragItemBounds
  420.     moveq        #$16,d0
  421.     _DragDispatch
  422.     ENDM
  423.  
  424. ;
  425. ;    FUNCTION GetDropLocation        (theDragRef : DragReference;
  426. ;                                     VAR dropLocation : AEDesc) : OSErr;
  427. ;
  428.  
  429.     MACRO
  430.     _GetDropLocation
  431.     moveq        #$17,d0
  432.     _DragDispatch
  433.     ENDM
  434.  
  435.  
  436. ;
  437. ;    FUNCTION SetDropLocation        (theDragRef : DragReference;
  438. ;                                     dropLocation : AEDesc) : OSErr;
  439. ;
  440.  
  441.     MACRO
  442.     _SetDropLocation
  443.     moveq        #$18,d0
  444.     _DragDispatch
  445.     ENDM
  446.  
  447.  
  448.  
  449. ; Getting Information About a Drag
  450.  
  451. ;
  452. ;    FUNCTION GetDragAttributes        (theDragRef : DragReference;
  453. ;                                     VAR flags : DragAttributes) : OSErr;
  454. ;
  455.  
  456.     MACRO
  457.     _GetDragAttributes
  458.     moveq        #$19,d0
  459.     _DragDispatch
  460.     ENDM
  461.  
  462.  
  463. ;
  464. ;    FUNCTION GetDragMouse            (theDragRef : DragReference;
  465. ;                                     VAR mouse : Point;
  466. ;                                     VAR pinnedMouse : Point) : OSErr;
  467. ;
  468.  
  469.     MACRO
  470.     _GetDragMouse
  471.     moveq        #$1A,d0
  472.     _DragDispatch
  473.     ENDM
  474.  
  475.  
  476. ;
  477. ;    FUNCTION SetDragMouse            (theDragRef : DragReference;
  478. ;                                     pinnedMouse : Point) : OSErr;
  479. ;
  480.  
  481.     MACRO
  482.     _SetDragMouse
  483.     moveq        #$1B,d0
  484.     _DragDispatch
  485.     ENDM
  486.  
  487.  
  488. ;
  489. ;    FUNCTION GetDragOrigin            (theDragRef : DragReference;
  490. ;                                     VAR initialMouse : Point) : OSErr;
  491. ;
  492.  
  493.     MACRO
  494.     _GetDragOrigin
  495.     moveq        #$1C,d0
  496.     _DragDispatch
  497.     ENDM
  498.  
  499.  
  500. ;
  501. ;    FUNCTION GetDragModifiers        (theDragRef : DragReference;
  502. ;                                     VAR modifiers : INTEGER;
  503. ;                                     VAR mouseDownModifiers : INTEGER;
  504. ;                                     VAR mouseUpModifiers : INTEGER) : OSErr;
  505. ;
  506.  
  507.     MACRO
  508.     _GetDragModifiers
  509.     moveq        #$1D,d0
  510.     _DragDispatch
  511.     ENDM
  512.  
  513.  
  514.  
  515. ; Drag Highlighting
  516.  
  517. ;
  518. ;    FUNCTION ShowDragHilite            (theDragRef : DragReference;
  519. ;                                     hiliteFrame : RgnHandle;
  520. ;                                     inside : Boolean) : OSErr;
  521. ;
  522.  
  523.     MACRO
  524.     _ShowDragHilite
  525.     moveq        #$1E,d0
  526.     _DragDispatch
  527.     ENDM
  528.  
  529.  
  530. ;
  531. ;    FUNCTION HideDragHilite            (theDragRef : DragReference) : OSErr;
  532. ;
  533.  
  534.     MACRO
  535.     _HideDragHilite
  536.     moveq        #$1F,d0
  537.     _DragDispatch
  538.     ENDM
  539.  
  540.  
  541. ;
  542. ;    FUNCTION DragPreScroll            (theDragRef : DragReference;
  543. ;                                     dH : INTEGER;
  544. ;                                     dV : INTEGER) : OSErr;
  545. ;
  546.  
  547.     MACRO
  548.     _DragPreScroll
  549.     moveq        #$20,d0
  550.     _DragDispatch
  551.     ENDM
  552.  
  553.  
  554. ;
  555. ;    FUNCTION DragPostScroll            (theDragRef : DragReference) : OSErr;
  556. ;
  557.  
  558.     MACRO
  559.     _DragPostScroll
  560.     moveq        #$21,d0
  561.     _DragDispatch
  562.     ENDM
  563.  
  564.  
  565. ;
  566. ;    FUNCTION UpdateDragHilite        (theDragRef : DragReference;
  567. ;                                     updateRgn : RgnHandle) : OSErr;
  568. ;
  569.  
  570.     MACRO
  571.     _UpdateDragHilite
  572.     moveq        #$22,d0
  573.     _DragDispatch
  574.     ENDM
  575.  
  576.  
  577.  
  578. ; Drag Manager Utilities
  579.  
  580. ;
  581. ;    FUNCTION WaitMouseMoved            (initialMouse : Point) : BOOLEAN;
  582. ;
  583.  
  584.     MACRO
  585.     _WaitMouseMoved
  586.     moveq        #$23,d0
  587.     _DragDispatch
  588.     ENDM
  589.  
  590.  
  591. ;
  592. ;    FUNCTION ZoomRects                (fromRect : Rect;
  593. ;                                     toRect : Rect;
  594. ;                                     zoomSteps : INTEGER;
  595. ;                                     acceleration : ZoomAcceleration) : OSErr;
  596. ;
  597.  
  598.     MACRO
  599.     _ZoomRects
  600.     moveq        #$24,d0
  601.     _DragDispatch
  602.     ENDM
  603.  
  604.  
  605. ;
  606. ;    FUNCTION ZoomRegion                (region : RgnHandle;
  607. ;                                     zoomDistance : Point;
  608. ;                                     zoomSteps : INTEGER;
  609. ;                                     acceleration : ZoomAcceleration) : OSErr;
  610. ;
  611.  
  612.     MACRO
  613.     _ZoomRegion
  614.     moveq        #$25,d0
  615.     _DragDispatch
  616.     ENDM
  617.  
  618.  
  619. ;
  620. ;    Will move to TextEdit.h
  621. ;
  622. ;    FUNCTION TEGetHiliteRgn            (region : RgnHandle;
  623. ;                                     hTE : TEHandle) : OSErr;
  624. ;
  625.  
  626.     MACRO
  627.     _TEGetHiliteRgn
  628.     move.w        #$000F,-(sp)
  629.     _TEDispatch
  630.     ENDM
  631.  
  632.  
  633.  
  634.     ENDIF    ; __INCLUDINGDRAG__
  635.  
  636.